home *** CD-ROM | disk | FTP | other *** search
/ LOGIC Apps / Logic-APPLE_II_APPS.iso / mac / LOGIC Apple II 5.25" Library - ProDOS / PRO081.dsk / MISCELLANEOUS / MISC.09.APLSOFT.txt < prev    next >
Text File  |  2012-02-16  |  2KB  |  56 lines

  1. Apple II
  2. Technical Notes
  3. _____________________________________________________________________________
  4.                                                   Developer Technical Support
  5.  
  6.  
  7. Apple II Miscellaneous
  8. #9:    AppleSoft Real Variable Storage
  9.  
  10. Revised by:    Pete McDonald                                    November 1988
  11. Written by:    Cameron Birse                                    December 1986
  12.  
  13. This Technical Note discusses real variable storage in AppleSoft BASIC.
  14. _____________________________________________________________________________
  15.  
  16. In AppleSoft BASIC, real variables (non-array) are stored sequentially 
  17. starting at the address pointed to by locations $69 and $6A.  The first two 
  18. bytes are the name of the variable, the third is the exponent, and the fourth 
  19. through seventh are the mantissa.
  20.  
  21. Exponent    The top bit of this byte is the sign of the exponent.  This sign 
  22.             bit is the opposite of normal sign bits, since zero is negative 
  23.             and one is positive.  The remainder of the byte minus one is the 
  24.             value of the exponent (i.e., 84 is a positive exponent of 3).
  25.  
  26. Mantissa    The mantissa is a binary fraction with the first bit being the 
  27.             sign bit (normal this time with zero being positive and one 
  28.             negative), and the remaining bits are fractional values starting 
  29.             with .5, .25, .125, etc.
  30.  
  31. The equation which follows is:  2^(Exponent-1) * 1.Mantissa
  32.  
  33. Examples
  34.  
  35. A = 3 (real variable equal to 3)
  36.  
  37. The seven bytes look like:    41    00                Variable name = A
  38.                               82                      Exponent = 1
  39.                               40    00    00    00    Mantissa = .5
  40.  
  41. which works out as:    2^1 * 1.5 = 3
  42.  
  43.  
  44. B = 5 (real variable equal to 5)
  45.  
  46. The seven bytes look like:    42    00                Variable name = B
  47.                               83                      Exponent = 2
  48.                               20    00    00    00    Mantissa = .25
  49.  
  50. which works out as:    2^2 * 1.25 = 5
  51.  
  52.  
  53. Further Reference
  54. o    AppleSoft BASIC Programmer's Reference Manual
  55.  
  56.